<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('考勤列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>考勤时间：</label>
                                <input type="text" class="time-input" id="attendMonth" data-type="month" name="attendMonth" th:value="${attendMonth}"/>
                            </li>
                            <li>
                                <label>考勤科室：</label>
                                <input type="text" name="attendName"/>
                            </li>
                            <li>
                                <label>员工姓名：</label>
                                <input type="text" name="userName"/>
                            </li>
                            <li>
                                <label>人员科室：</label>
                                <input type="text" name="deptName"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-table-export-js" />
    <th:block th:include="include :: bootstrap-table-fixed-columns-js" />
    <script th:inline="javascript">
        var prefix = ctx + "report/attend";

        var datas = [[${@dict.getType('attend_status')}]];
        var dutys = [[${@dict.getType('basic_work_duty')}]];
        var types = [[${@dict.getType('basic_user_type')}]];
        var technicals = [[${@dict.getType('basic_user_technical')}]];
        var positions = [[${@dict.getType('basic_user_position')}]];
        var attends = [[${@dict.getType('attend_type')}]];
        var posts = [[${@dict.getType('post_type')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                modalName: "考勤报表",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                showExport: true,
                exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel'], // 导出的文件类型
                exportOptions: {
                    fileName: $("#attendMonth").val() + '考勤报表',    // 文件名称设置
                    mso: {
                        worksheetName: '考勤报表',
                        //修复导出数字不显示为科学计数法
                        onMsoNumberFormat: function (cell, row, col) {
                            return !isNaN($(cell).text())?'\\@':'';
                        }
                    }
                },
                fixedColumns: true,
                fixedNumber: 5,
                columns: [
                    {
                        field: 'userName',
                        title: '员工姓名'
                    },
                    {
                        field: 'idCard',
                        title: '身份证号',
                        formatter: function(value, row, index) {
                            return '&nbsp;' + value;
                        }
                    },
                    {
                        field: 'attendName',
                        title: '考勤科室',
                        sortable: true
                    },
                    {
                        field: 'deptName',
                        title: '员工科室',
                        sortable: true
                    },
                    {
                        field: 'userType',
                        title: '人员类别',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(types, value);
                        }
                    },
                    {
                        field: 'salary',
                        title: '岗位工资'
                    },
                    {
                        field: 'insurance',
                        title: '保险基数'
                    },
                    {
                        field: 'workDuty',
                        title: '编制情况',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(dutys, value);
                        }
                    },
                    {
                        field: 'userPosition',
                        title: '职位类别',
                        sortable: true,
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(positions, value);
                        }
                    },
                    {
                        field: 'technicalType',
                        title: '技术类别',
                        sortable: true,
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(technicals, value);
                        }
                    },
                    {
                        field: 'attendType',
                        title: '考勤分类',
                        sortable: true,
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(attends, value);
                        }
                    },
                    {
                        field: 'postType',
                        title: '岗位属性',
                        sortable: true,
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(posts, value);
                        }
                    },
                    {
                        field: 'day1',
                        title: '1',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day2',
                        title: '2',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day3',
                        title: '3',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day4',
                        title: '4',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day5',
                        title: '5',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day6',
                        title: '6',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day7',
                        title: '7',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day8',
                        title: '8',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day9',
                        title: '9',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day10',
                        title: '10',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day11',
                        title: '11',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day12',
                        title: '12',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day13',
                        title: '13',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day14',
                        title: '14',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day15',
                        title: '15',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day16',
                        title: '16',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day17',
                        title: '17',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day18',
                        title: '18',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day19',
                        title: '19',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day20',
                        title: '20',formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day21',
                        title: '21',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day22',
                        title: '22',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day23',
                        title: '23',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day24',
                        title: '24',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day25',
                        title: '25',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day26',
                        title: '26',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day27',
                        title: '27',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day28',
                        title: '28',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day29',
                        title: '29',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day30',
                        title: '30',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        field: 'day31',
                        title: '31',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                    {
                        title: '出勤',
                        formatter: function(value, row, index) {
                            return countVac(row, '01');
                        }
                    },
                    {
                        title: '休息',
                        formatter: function(value, row, index) {
                            return countVac(row, '02');
                        }
                    },
                    {
                        title: '病假',
                        formatter: function(value, row, index) {
                            return countVac(row, '03');
                        }
                    },
                    {
                        title: '事假',
                        formatter: function(value, row, index) {
                            return countVac(row, '04');
                        }
                    },
                    {
                        title: '工伤',
                        formatter: function(value, row, index) {
                            return countVac(row, '05');
                        }
                    },
                    {
                        title: '婚丧假',
                        formatter: function(value, row, index) {
                            return countVac(row, '06');
                        }
                    },
                    {
                        title: '探亲假',
                        formatter: function(value, row, index) {
                            return countVac(row, '07');
                        }
                    },
                    {
                        title: '调休',
                        formatter: function(value, row, index) {
                            return countVac(row, '08');
                        }
                    },
                    {
                        title: '旷工',
                        formatter: function(value, row, index) {
                            return countVac(row, '09');
                        }
                    },
                    {
                        title: '加班',
                        formatter: function(value, row, index) {
                            return countVac(row, '10');
                        }
                    },
                    {
                        title: '工休假',
                        formatter: function(value, row, index) {
                            return countVac(row, '12');
                        }
                    },
                    {
                        title: '产假',
                        formatter: function(value, row, index) {
                            return countVac(row, '13');
                        }
                    },
                    {
                        title: '其他',
                        formatter: function(value, row, index) {
                            return countVac(row, '11');
                        }
                    },
                    {
                        field: 'remark',
                        title: '备注'
                    }]
            };
            $.table.init(options);
        });

        function countVac(row, value) {
            var count = 0;
            if(row.day1 == value){
                count ++;
            }
            if(row.day2 == value){
                count ++;
            }
            if(row.day3 == value){
                count ++;
            }
            if(row.day4 == value){
                count ++;
            }
            if(row.day5 == value){
                count ++;
            }
            if(row.day6 == value){
                count ++;
            }
            if(row.day7 == value){
                count ++;
            }
            if(row.day8 == value){
                count ++;
            }
            if(row.day9 == value){
                count ++;
            }
            if(row.day10 == value){
                count ++;
            }
            if(row.day11 == value){
                count ++;
            }
            if(row.day12 == value){
                count ++;
            }
            if(row.day13 == value){
                count ++;
            }
            if(row.day14 == value){
                count ++;
            }
            if(row.day15 == value){
                count ++;
            }
            if(row.day16 == value){
                count ++;
            }
            if(row.day17 == value){
                count ++;
            }
            if(row.day18 == value){
                count ++;
            }
            if(row.day19 == value){
                count ++;
            }
            if(row.day20 == value){
                count ++;
            }
            if(row.day21 == value){
                count ++;
            }
            if(row.day22 == value){
                count ++;
            }
            if(row.day23 == value){
                count ++;
            }
            if(row.day24 == value){
                count ++;
            }
            if(row.day25 == value){
                count ++;
            }
            if(row.day26 == value){
                count ++;
            }
            if(row.day27 == value){
                count ++;
            }
            if(row.day28 == value){
                count ++;
            }
            if(row.day29 == value){
                count ++;
            }
            if(row.day30 == value){
                count ++;
            }
            if(row.day31 == value){
                count ++;
            }
            return count;
        }
    </script>
</body>
</html>